package com.leoman.plz_p.adapter;

import android.content.Context;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.bumptech.glide.Glide;
import com.leoman.plz_p.R;
import com.leoman.plz_p.module.bean.MissionBean;

import cn.com.corelib.utils.adapter.BaseAdapterHelper;
import cn.com.corelib.utils.adapter.normal.QuickAdapter;

/**
 * Created by guoh on 2018/7/21.
 */
public class MissionRecordAdapter extends QuickAdapter<MissionBean> {

    public MissionRecordAdapter(Context context) {
        super(context, R.layout.item_mission);
    }


    @Override
    protected void convert(BaseAdapterHelper helper, MissionBean item, int position) {
        if (item!=null) {
            Glide.with(context).load(item.getImage()).into((ImageView) helper.getView(R.id.iv_image));
            helper.setText(R.id.tv_text, item.getName());
        }
        LinearLayout.LayoutParams progressParams= (LinearLayout.LayoutParams) helper.getView(R.id.v_progress).getLayoutParams();
        try {
            progressParams.weight=Integer.parseInt(item.getS());
            helper.getView(R.id.v_progress).setLayoutParams(progressParams);
            helper.setVisible(R.id.iv_complete,progressParams.weight==100);
        }catch (Exception e){
            progressParams.weight=0;
            helper.getView(R.id.v_progress).setLayoutParams(progressParams);
            helper.setVisible(R.id.iv_complete,false);
        }

    }
}
